#ifndef dq_Model_h
#define dq_Model_h

#include "Singleton.h"
#include "DeclareList.h"
#include <map>

namespace serika
{
	namespace dq
	{
		class Model
		{
		public:
			Model();
			~Model();

		public:
			void Initialize();
			void Finalize();

		public:
			static const Items& GetItems();
			static void AddItem(Item* item);
			static void AddItems(const Items& items);
			static void AddNewItem(Item* item);
			static void PullNewItems(Items& items);
			static void SetUnconfirm(Item* item);

			static const PropertyTemplates& GetPropertyTemplates(int itemType);
			static void AddPropertyTemplates(int itemType, const PropertyTemplates& tmpls);

			static const ItemCategories& GetItemCategories(int itemType);
			static void AddItemCategories(int itemType, const ItemCategories& categories);

			static const Towns& GetTowns();
			static void AddTowns(const Towns& towns);

			static const Alchemies& GetAlchemies();
			static void AddAlchemies(const Alchemies& alchemies);

		private:
			Items mItems;
			Items mNewItems;
			Item* mUnconfirm;
			Towns mTowns;
			typedef std::map<int, PropertyTemplates> PropTmplMap;
			PropTmplMap mPropTmplMap;
			typedef std::map<int, ItemCategories> CategoriesMap;
			CategoriesMap mCategoriesMap;
			Alchemies mAlchemies;

			template<class List>
			void ClearList(List& l);
			template<class Map>
			void ClearMap(Map& m);

			void SortItems();
		};

		typedef Singleton<Model> ModelSngl;
	}
}

#endif
